#include "createcompletedcompetition.h"
#include "ui_createcompletedcompetition.h"

CreateCompletedCompetition::CreateCompletedCompetition(SystemController *controller, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CreateCompletedCompetition)
{
    ui->setupUi(this);
    this->systemController = controller;
}

CreateCompletedCompetition::~CreateCompletedCompetition()
{
    delete ui;
}

/*!
  \fn accept
  Function called when Dialog is accepted
  */
void CreateCompletedCompetition::accept()
{
    bool acceptForm = true;
    if (getName() == "")
    {
        this->systemController->showErrorDialog(this, tr("Field has no value"), tr("Please insert a text into the field \"Name\""));
        acceptForm = false;
        return;
    }
    if (getCity() == "")
    {
        this->systemController->showErrorDialog(this, tr("Field has no value"), tr("Please insert a text into the field \"City\""));
        acceptForm = false;
        return;
    }

    if (acceptForm)
        QDialog::accept();
}

/////////////////////
//Getter Functions//
///////////////////

QString CreateCompletedCompetition::getName()
{
    return ui->lineEdit->text();
}

QString CreateCompletedCompetition::getCity()
{
    return ui->cityLineEdit->text();
}

QDate CreateCompletedCompetition::getDate()
{
    return ui->dateDateEdit->date();
}

QString CreateCompletedCompetition::getMail()
{
    return ui->contactMailLineEdit->text();
}

QString CreateCompletedCompetition::getWeb()
{
    return ui->contactWebLineEdit->text();
}

